﻿@using FE.Shared
@using FE.Shared.Enum
@model FE.Shared.ServerPathSettings

<style>
    .msg {
        width: 50%;
        margin: 20px;
    }

    .validate {
        color: red;
    }
</style>

<script>

    $(function() {
        var Toast = Swal.mixin({
            toast: true,
            position: 'top-end',
            showConfirmButton: false,
            timer: 3000
        });

        $('.btn-modal1').click(function() {
            console.log("button");
            $(document).Toasts('create',
                {
                    class: 'bg-success',
                    title: 'Toast Title',
                    subtitle: 'Subtitle',
                    body: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr.'
                });
        });
    });

    function setFileMode(type) {

        var mode = document.getElementById("FileMode");

        mode.value = type;
    }



    $(document).ready(function() {
        console.log("load");
        //$("#SftpFileAttachmentRootPath_Password").val($("#hidRootPwd").val());
        //$("#SftpPdfGeneratedServerPath_Password").val($("#hidPdfPwd").val());


        //$(document).Toasts('create',
        //    {
        //        class: 'bg-warning',
        //        title: 'Toast Title',
        //        subtitle: 'Subtitle',
        //        body: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr.'
        //    });

    });






</script>

<!-- Main content -->
<section class="content">
    <div class="container-fluid">

        <!-- Timeline example  -->
        <div class="row">
            <div class="col-md-12">
                <!-- The time line -->
                <form asp-action="Update">

                    <input type="hidden" asp-for="FileMode" />
                    @*<input id="hidRootPwd" type="hidden" asp-for="SftpFileAttachmentRootPath.Password" />
                        <input id="hidPdfPwd" type="hidden" asp-for="SftpPdfGeneratedServerPath.Password" />*@
                    <div class="callout callout-info">

                        @if (ViewBag.FileMode == 1)
                        {
                            <h5><small> 目前使用的设置为</small> [文件夹模式]</h5>
                        }
                        else if (ViewBag.FileMode == 2)
                        {
                            <h5><small> 目前使用的设置为</small> [SFTP]</h5>
                        }
                        else
                        {
                            <h5><small> 您还没有设置</small> [附件模式]</h5>
                        }

                    </div>
                    @if (ViewBag?.ResultCode == ResultCode.Normal)
                    {

                    }
                    else if (ViewBag?.ResultCode == ResultCode.Failed)
                    {
                        <div class="col-md-6 col-sm-6 col-6">
                            <div class="info-box bg-danger">
                                <span class="info-box-icon"><i class="fas fa-comments"></i></span>

                                <div class="info-box-content">
                                    <span class="info-box-text">Failed!</span>
                                    <span class="info-box-number"></span>

                                    <div class="progress">
                                        <div class="progress-bar" style="width: 100%"></div>
                                    </div>
                                    <span>
                                        详细信息:@ViewBag.Msg
                                    </span>
                                </div>
                                <!-- /.info-box-content -->
                            </div>
                            <!-- /.info-box -->
                        </div>
                    }
                    else if (ViewBag?.ResultCode == ResultCode.Success)
                    {
                        <div class="col-md-6 col-sm-6 col-6">
                            <div class="info-box bg-success">
                                <span class="info-box-icon"><i class="far fa-thumbs-up"></i></span>

                                <div class="info-box-content">
                                    <span class="info-box-text">Successfully!</span>
                                    <span class="info-box-number"></span>

                                    <div class="progress">
                                        <div class="progress-bar" style="width: 100%"></div>
                                    </div>
                                    <span class="progress-description">
                                        保存成功!
                                    </span>
                                </div>
                                <!-- /.info-box-content -->
                            </div>
                            <!-- /.info-box -->
                        </div>
                    }

                    <div class="timeline">
                        <!-- timeline time label -->
                        <div class="time-label">
                            <span class="bg-blue">普通模式(window共享文件夹)</span>
                        </div>
                        <!-- /.timeline-label -->
                        <!-- timeline item -->
                        <div>
                            <i class="fas fa-folder bg-blue"></i>
                            <div class="timeline-item">

                                <h3 class="timeline-header"><a href="#">文件夹设置</a> </h3>

                                <div class="timeline-body">

                                    <!-- general form elements -->
                                    <!-- /.card-header -->
                                    <div class="card-body">
                                        <div class="form-group">
                                            <label for="exampleInputBorder">附件上传根目录路径:</label>
                                            <input type="text" class="form-control form-control-border" asp-for="FileAttachmentRootPath" placeholder="d://Media//attachment">
                                            <span class="validate" asp-validation-for="FileAttachmentRootPath"></span>
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputBorderWidth2">生成PDF的路径: </label>
                                            <input type="text" class="form-control form-control-border border-width-2" asp-for="PdfGeneratedServerPath" placeholder="D:\Media\FileManage\swfFiles">
                                            <span class="validate" asp-validation-for="PdfGeneratedServerPath"></span>
                                        </div>
                                    </div>
                                    <div class="card-footer">
                                        <button type="submit" class="btn btn-primary" onclick="setFileMode(1);">保存和测试连接</button>
                                    </div>


                                </div>

                            </div>
                        </div>


                        <!-- timeline time label -->
                        <div class="time-label">
                            <span class="bg-green">SFTP模式设置</span>
                        </div>

                        <!-- /.timeline-label -->
                        <!-- timeline item -->
                        <div>
                            <i class="fa fa-upload bg-purple"></i>
                            <div class="timeline-item">
                                <h3 class="timeline-header"><a href="#">附件上传根目录</a> SFTP设置</h3>
                                <div class="timeline-body">

                                    <!-- general form elements -->
                                    <!-- /.card-header -->
                                    <div class="card-body">
                                        <div class="form-group">
                                            <label for="exampleInputBorder">SFTP服务器地址:</label>
                                            <input type="text" class="form-control form-control-border" asp-for="SftpFileAttachmentRootPath.Host" placeholder="10.62.11.11">
                                            <span class="validate" asp-validation-for="SftpFileAttachmentRootPath.Host"></span>
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputBorder">文件夹路径</label>
                                            <input type="text" class="form-control form-control-border" asp-for="SftpFileAttachmentRootPath.Path" placeholder="/root/upload">
                                            <span class="validate" asp-validation-for="SftpFileAttachmentRootPath.Path"></span>
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputRounded0">账号:</label>
                                            <input type="text" class="form-control rounded-0" asp-for="SftpFileAttachmentRootPath.UserName" placeholder="fe">
                                            <span class="validate" asp-validation-for="SftpFileAttachmentRootPath.UserName"></span>
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputRounded0">密码:</label>
                                            <input type="password" class="form-control rounded-0" asp-for="SftpFileAttachmentRootPath.Password" placeholder="Password">
                                            <span class="validate" asp-validation-for="SftpFileAttachmentRootPath.Password"></span>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- END timeline item -->
                        <!-- timeline item -->
                        <div>
                            <i class="fas fa-file-upload bg-yellow"></i>

                            <div class="timeline-item">


                                <h3 class="timeline-header"><a href="#">PDF生成目录</a> SFTP设置</h3>

                                <div class="timeline-body">
                                    <!-- general form elements -->
                                    <!-- /.card-header -->
                                    <div class="card-body">
                                        <div class="form-group">
                                            <label for="exampleInputBorder">PDF生成目录的SFTP服务器地址:</label>
                                            <input type="text" class="form-control form-control-border" asp-for="SftpPdfGeneratedServerPath.Host" placeholder="10.62.11.11">
                                            <span class="validate" asp-validation-for="SftpPdfGeneratedServerPath.Host"></span>
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputBorder">文件夹路径</label>
                                            <input type="text" class="form-control form-control-border" asp-for="SftpPdfGeneratedServerPath.Path" placeholder="/root/upload">
                                            <span class="validate" asp-validation-for="SftpPdfGeneratedServerPath.Path"></span>
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputRounded0">账号:</label>
                                            <input type="text" class="form-control rounded-0" asp-for="SftpPdfGeneratedServerPath.UserName" placeholder="fe">
                                            <span class="validate" asp-validation-for="SftpPdfGeneratedServerPath.UserName"></span>
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputRounded0">密码:</label>
                                            <input type="password" class="form-control rounded-0" asp-for="SftpPdfGeneratedServerPath.Password" placeholder="Password">
                                            <span class="validate" asp-validation-for="SftpPdfGeneratedServerPath.Password"></span>
                                        </div>
                                    </div>

                                </div>
                                <div class="timeline-footer">

                                    <button type="submit" onclick="setFileMode(2)" class="btn btn-primary btn-modal1">保存和测试连接</button>

                                    <a href="#" class="btn btn-sm bg-maroon">See comments</a>
                                </div>

                            </div>
                        </div>



                    </div>

                </form>
            </div>
            <!-- /.col -->
        </div>
    </div>
    <!-- /.timeline -->

</section>



